﻿@{
    ViewBag.Title = "JQueryCallback";
    Layout = "~/Views/Shared/_Page.cshtml";
}

<h2>JQueryCallback</h2>
<br />
<h3>Path: @ViewBag.Path</h3>
<br />
<h3>See the result on console</h3>
<br />

<script type="text/javascript">
    function callback_func1(value) {
        ZEUS.DEBUG.log("Callback Function[1] Returns: " + value);
    }

    function callback_func2(value) {
        ZEUS.DEBUG.log("Callback Function[2] Returns: " + value);
    }

    $(document).ready(function () {
        // define callback list object
        var callbacks = $.Callbacks();

        // add func1 to callback list and fires func1
        ZEUS.DEBUG.log("add func1 to callback list and fires func1");
        callbacks.add(callback_func1);
        callbacks.fire("First");
        ZEUS.DEBUG.log("*************************************************************************");

        // add func2 to callback list and fires both func1 and func2
        ZEUS.DEBUG.log("add func2 to callback list and fires both func1 and func2");
        callbacks.add(callback_func2);
        callbacks.fire("Second");
        ZEUS.DEBUG.log("*************************************************************************");

        // remove func2 from callback list
        ZEUS.DEBUG.log("remove func2 from callback list");
        callbacks.remove(callback_func2);

        // fires only func1
        ZEUS.DEBUG.log("fires only func1");
        callbacks.fire("Third");
    });
</script>